<template>
	<view class="sticky">
		<view class="range">
			<view class="sticky-range">当前选择置顶范围:</view>
			<view v-if="true" class="labels">
				<view v-for="(item,index) in labels" :key="index">
					<view class="label">
						{{item}}
						<image src='../../../static/删除.png' class="delete"></image>
					</view>
				</view>
				<view v-if="true" class="more">添加更多</view>
			</view>
			<view v-else class="noLabel">
				点击选择置顶范围>
			</view>
		</view>
		<view class="sticky-time">
			<view>
				<view style="background: #EFF0F5;padding: 20rpx;">
					请选择置顶时间:
				</view>
				<view class="check-time">
					<span>置顶时间:</span>
					<picker :range="columns" :value="timeIndex" @change="bindPickerChange">
						<view class="time">
							<input type="text" v-model="time" />
							<image class="moreImage" src="../../../static/下箭头浅.png" mode="more-time"></image>
						</view>
					</picker>
				</view>
			</view>
			<view class="expiration-time">
				<view>
					置顶到期时间:
				</view>
				<view class="time">
					{{expirationTime}}
				</view>
			</view>
			<view class="expiration-time">
				<view>
					消耗积分:
				</view>
				<view style="color: #007AFF;margin-left: 20rpx;">
					{{consume}}
				</view>
			</view>
		</view>
		<view class="confirm-top">
			<view class="top">
				确定置顶
			</view>
		</view>
		<view class="rule">
			<view class="left"></view>
			<view class="content">置顶规则</view>
			<view class="right"></view>
		</view>
		<view class="text">
			<view class="one">1.置顶全国每天消耗100积分;置顶市每天消耗10积分;置顶省或直辖市每天消耗50积分。</view>
			<view class="two">2.最多可同时置顶3个省、2个市。全国不能和省(直辖市)、市同时存在</view>
			<view class="three">3.如有任何疑问欢迎致电鱼泡客服,客服电话:<a class="btn-phone" href="tel:phoneNumber" style="color: #007AFF;">400-838-1888</a></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				labels: [1, 2, 3, 4],
				columns: ["24小时(1天)", "48小时(2天)", "72小时(3天)", "4天", "5天", "6天", "7天", "8天", "9天", "10天", "15天", "30天", "60天"],
				time: "",
				timeIndex: 0,
				expirationTime: "",
				consume: ""
			}
		},
		methods: {
			bindPickerChange(e) {
				debugger
				this.time = this.columns[e.target.value]
				var nowDate = new Date()
				let nowTime
				if (this.columns.indexOf(this.time) != -1) {
					if (this.columns.indexOf(this.time) + 1 <= 10) {
						nowTime = (this.columns.indexOf(this.time) + 1)
					}else if(this.columns.indexOf(this.time) + 1>10){
						nowTime = this.columns[this.columns.indexOf(this.time)].slice(0,2)
						nowTime =  Math.round(nowTime)
					}
					var date = new Date()
					date.setDate(nowDate.getDate()+nowTime)
					let year = date.getFullYear();
					let month = date.getMonth() + 1;
					if (month < 10) {
						month = 0 + "" + month
					}
					let day = date.getDate();
					if (day < 10) {
						day = 0 + "" + day
					}
					let hours = date.getHours();
					if (hours < 10) {
						hours = 0 + "" + hours
					}
					let minutes = date.getMinutes();
					if (minutes < 10) {
						minutes = 0 + "" + minutes
					}
					console.info(year + "-" + month + "-" + day + "-" + hours + ":" + minutes)
					this.expirationTime = year + "-" + month + "-" + day + "-" + hours + ":" + minutes
				}

			},
		}
	}
</script>

<style lang="scss" scoped>
	.sticky {
		background: #dadbdf;
		min-height: 100vh;
		.range {
			padding: 20rpx;

			.sticky-range {
				line-height: 60rpx;
			}

			.labels {
				display: flex;
				font-size: 32rpx;
				flex-wrap: wrap;

				.label {
					border: solid 1px #737373;
					position: relative;
					font-size: 32rpx;
					padding: 16rpx 30rpx;
					border-radius: 10rpx;
					margin-right: 40rpx;
					margin-bottom: 40rpx;

					.delete {
						width: 40rpx;
						height: 40rpx;
						position: absolute;
						top: -4rpx;
						right: -4rpx;
					}
				}

				.more {
					text-align: center;
					background: #007AFF;
					color: #FFFFFF;
					padding: 16rpx 30rpx;
					border-radius: 10rpx;
					margin-bottom: 40rpx;
				}
			}
		}

		.sticky-time {
			background: #FFFFFF;
			font-size: 32rpx;

			.check-time {
				background: #FFFFFF;
				display: flex;
				align-items: center;
				border-bottom: solid 1px #d9d9d9;
				margin: 0 20rpx;
				padding: 20rpx 0;

				.moreImage {
					width: 50rpx;
					height: 50rpx;
				}

				.time {
					display: flex;
					align-items: center;
					width: 70vw;
					justify-content: space-between;
					margin-left: 20rpx;
				}
			}
			.expiration-time{
				display: flex;
				margin: 0 20rpx;
				padding: 20rpx 0;
				border-bottom: solid 1px #d9d9d9;
				.time{
					margin-left: 20rpx;
				}
			}
		}
		.confirm-top{
			display: flex;
			justify-content: center;
			margin-top: 30rpx;
			.top{
				font-size: 32rpx;
				text-align: center;
				background: #007AFF;
				padding: 16rpx 20rpx;
				color: #FFFFFF;
				border-radius: 14rpx;
				width: 60vw;
			}
		}
		.rule{
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 30rpx;
			margin: 30rpx 0;
			.left,.right{
				width: 200rpx;
				border-bottom:solid 1px #000000 ;
			}
		}
		.text{
			margin: 0 20rpx;
			font-size: 30rpx;
			line-height: 60rpx;
			.btn-phone{
				text-decoration: none;
				
			}
		}
		
	}
</style>
